package per.hx.bs.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import per.hx.bs.base.entity.EmailVO;
import per.hx.bs.topic.sender.TopicSender;

/**
 * @author HuXing
 * @date 2018/4/26  14:27
 */
@RestController
@RequestMapping(value = "email-service/email")
public class EmailApiServiceImpl {

    private final
    TopicSender topicSender;

    @Autowired
    public EmailApiServiceImpl(TopicSender topicSender) {
        this.topicSender = topicSender;
    }

    @PostMapping(value = "/email")
    public int sendEmail(@RequestBody EmailVO emailVO) {
        return topicSender.send(emailVO);
    }

    @GetMapping(value = "/email")
    public int sendEmail() {
        EmailVO emailVO = new EmailVO();
        String[] emalis = {"931307458@qq.com"};
        emailVO.setEmail(emalis);
        emailVO.setSubject("主题");
        emailVO.setContent("滴答滴答滴答滴答滴答滴答滴答多多多");
        return topicSender.send(emailVO);
    }
}
